package com.game.worm.mobile.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.game.worm.mobile.view.details.DetailsActivity;
import com.game.worm.mobile.view.list.taglist.GameListActivity;

/**
 * Created by d_xxiang on 2018/5/19.
 */

public class GameHelper {

    private static Context context;

    public static void init(Context con ){
        context = con;

    }

    public static View.OnClickListener getOnItemClickListener(final String id){
        return new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goToGameDetailsView(id);
            }
        };
    }

    public static void startNewIntent(Class<?> cls){
        Intent intent = new Intent(context, cls);
        context.startActivity(intent);
    }

    public static void goToGameDetailsView(String id){
        Bundle bundle = new Bundle();
        bundle.putString(GameExtras.EXTRAS_GAME_ID,id);
        startNewIntentWithBundle(DetailsActivity.class,bundle);
    }

    public static void goToTagGameListView(String tag,String tagName,int type){
        Bundle bundle = new Bundle();
        bundle.putString(GameExtras.EXTRAS_GAME_TAG_ID,tag);
        bundle.putString(GameExtras.EXTRAS_GAME_TAG_NAME,tagName);
        bundle.putInt(GameExtras.EXTRAS_GAME_BY_WHAT,type);
        startNewIntentWithBundle(GameListActivity.class,bundle);
    }

    private static void startNewIntentWithBundle(Class<?> cls, Bundle bundle){
        Intent intent = new Intent(context, cls);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }
}
